package com.bw.module_video_detail.widget

import android.app.Dialog
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import androidx.fragment.app.FragmentManager
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.bw.module_video_detail.R



class DanMuBottomSheetDialog: BottomSheetDialogFragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.view_danmu, container, false)
        initView(view)
        return view
    }

    var ivSend:ImageView?= null
    var etContent:EditText?=null

    var listener:DanMuListener? = null

    fun setDanMuListener(_listener:DanMuListener){
        listener=_listener
    }

    private fun initView(view: View?) {
        etContent = view?.findViewById<EditText>(R.id.et_home_detail_view_danmu_content)!!
        ivSend= view?.findViewById<ImageView>(R.id.iv_home_detail_view_danmu_send)!!

        ivSend?.setOnClickListener {
            if(listener != null){
                listener?.onClick()
            }
        }
    }

    fun close(){
        etContent?.text?.clear()
        dismiss()
    }

    fun show(fm:FragmentManager){
        show(fm,"DanMuBottomSheetDialog")
    }
    interface DanMuListener{
        fun onClick()
    }
}